<?php
require_once("lib.php");
require_once("MyTopoTileService.php");

$encMultiTracks = "";
if (isset($_POST["tracks"])) {
	$multiTracks["multitracks"] = array();
	foreach ($_POST["tracks"] as $trackID => $flag) {
		$multiTracks["multitracks"][] = $trackID;
	}
	$encMultiTracks = base64_encode(json_encode($multiTracks));
} elseif (isset($_GET["tracks"])) {
	$encMultiTracks = $_GET["tracks"];
}

$google_api_id = GOOGLE_API_ID;

$htmlTitle = "Hikes and Things: map view";
echo <<<CONTENT
<!DOCTYPE html>
<html lang="en" class="map">
	<head>
		<title>$htmlTitle</title>
        <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
		<link href="style.css" rel="stylesheet" type="text/css">
		$analytics
	</head>
	<body class="map">
        <div class="navbar navbar-static">
            <div class="navbar-inner">
                <div class="container" style="width: auto;">
                    <a class="brand" href="#">Map View</a>
                    <ul class="nav" role="navigation">
                        <li class="divider-vertical"></li>
                        <li><a href="index.php">Tracks</a></li>
                    </ul>
                    <ul class="nav pull-right">
                        <li class="divider-vertical"></li>
                        <li>$logInOut</li>
                    </ul>
                </div>
            </div>
        </div>
        <div id="map_canvas" data-m="$encMultiTracks"></div>
        <script src="jquery-1.9.1.min.js"></script>
        <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key=$google_api_id&sensor=false"></script>
		<script type="text/javascript" src="http://www.mytopo.com/TileService/Scripts/trimble.mytopo.v3.js?partnerID=$mytopo_partnerID&hash=$mytopo_hash"></script> 
        <script src="map.js"></script>
		<link href="style.css" rel="stylesheet" type="text/css">
    </body>
</html>
CONTENT;
?>
